package com.dwcode.macro.config;

import com.dwcode.macro.intercepter.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Autowired
    private LoginInterceptor interceptor;
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
//        registry.addViewController("/admin/login").setViewName("admin/login");
//        registry.addViewController("/admin/register").setViewName("admin/register");
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(interceptor).addPathPatterns("/**")
                .excludePathPatterns("/login","/register","/assets/**","/bootstrap/**","/validation");
    }
}
